package com.balabala.gym_system.kafkaConsumer;

import com.balabala.gym_system.constant.CoachConstant;
import com.balabala.gym_system.constant.KafkaConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * zl
 */
@Component
@Slf4j
public class KafkaConsumer {

    @Autowired
    RedisTemplate redisTemplate;

    @KafkaListener(topics = KafkaConstant.COURSE_CARD_CLEAR)
    public void clearCourseCardCache(ConsumerRecord  record)
    {
        log.info("开始清空缓存中。。。");
        log.info("更新的教练信息{}：",record.value());
        redisTemplate.delete(CoachConstant.COACH_CACHE+record.value());
        log.info("清除完毕。。。");
    }

}
